package com.zzf.concurrent.example.design.pattern.observer.thread.example;

import lombok.extern.slf4j.Slf4j;

/**
 * @author GaoFeng2017
 * @date 2019/9/6 11:03
 */
@Slf4j
public class LifeCycleListener implements ThreadListener {

    @Override
    public synchronized void handle(AbstractRunnableObserver.RunnableObserverEvent event) {

        AbstractRunnableObserver.ThreadStatus threadStatus = event.getThreadStatus();
        Thread target = event.getTarget();
        Throwable cause = event.getCause();
        log.info("thread status is update, Thread name : {}, Thread status：{}",
                threadStatus, target.getName());

        if (cause != null) {
            cause.printStackTrace();
        }

    }
}
